#ifndef NET_DEVICE_H
#define NET_DEVICE_H

#include <string>
#include <queue>

#include "dataDevice.h"
#include "thread.h"

using std::string;
using std::queue;

const string serialName = "/dev/ttyTX1";
const string serialSpeed = "57600";

const int maxSendBuffSize = 80;
const int sendDataSize = 22;


enum states{START, START2, ACK6, LEN35, ACK35, DATA};
enum sendStates{IDLE, SEND, WAITACK, POP};

struct sendBuff
{
	int size;
	char buff[maxSendBuffSize];
};

class FTTMDevice : public Thread
{
public:
	FTTMDevice();
	~FTTMDevice();
	bool on();
	void setup();
	void run();
	bool off(); 

private:
	dataDevice *device;
	queue<sendBuff> *sendBuffQ;
	bool sendable;
	bool turnedON;
	sendBuff *sendB;

	unsigned short int GetCrc16(char* InStr, unsigned int len);
	int litend(void);
	int pack(char *buff, int size, char *sbuff);
	int write(char* buff, int size); 
};


#endif //NET_DEVICE_H
